home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / debugger / ups-2.006 / ups-2.45.2-linux-0.2.diff
Encoding:
Text File  |  1994-03-10  |  26.7 KB  |  1,000 lines

  1. UPS was written by Mark Russell <mtr.ukc.ac.uk>.
  2.  
  3. Six months ago I ported the UPS debugger to Linux.  Since then I
  4. have found a few bugs in the port and I added support for more UPS
  5. features.  More importantly, GCC seems to have changed the debugging
  6. information it generates in such a way that the old UPS will hardly
  7. run at all.  So I have patched things up as best as I can and created
  8. a second revision of the diffs.
  9.  
  10. The file is currently available at:
  11.  
  12.   sunsite.unc.edu:/pub/Linux/Incoming/ups-2.45.2-linux-0.2.diff.gz
  13.  
  14. and likely soon at:
  15.  
  16.   sunsite.unc.edu:/pub/Linux/devel/debuggers/ups-2.45.2-linux-0.2.diff.gz
  17.  
  18. These diffs should be applied to a virgin UPS distribution such as:
  19.  
  20.   ftp.x.org:/contrib/ups-2.45.2.tar.Z
  21.  
  22. Changes since the previous version:
  23.  
  24. * support for attaching to already running processes
  25. * calling target functions (your own code) from a breakpoint works
  26. * the special include directory is no longer needed with libc 4.5.17 or later
  27. * the Imakefiles probably work
  28. * UPS now pretends to understand `long long' and `unsigned long long' types
  29. * UPS quietly tolerates the `long double' type
  30. * UPS understands octal numbers in debugging stabs
  31.  
  32. There are only two real problems with UPS on Linux.  One is due to
  33. a limitation in UPS and the other is due to a limitation in Linux.
  34.  
  35. * Linux makes use of inlined functions in the libc include files.  UPS
  36.   does not correctly handle the case of executable code lines occuring
  37.   in an included file.  Fixing this problem would be non-trivial so I
  38.   didn't do it.  The symptom is that one freqently gets the message
  39.   `No executable code on line' when trying to set a breakpoint.  As a
  40.   work-around you can include a small dummy function at the beginning
  41.   of any file which shows this problem, e.g. `static void dummy(void) {}'.
  42.  
  43. * When the debugged program is running of its own accord and doesn't
  44.   hit a breakpoint, it is impossible to stop the program from UPS.
  45.   This is because Linux does not (yet) support asynch I/O.  As a
  46.   workaround, you can send a signal to the process from another window
  47.   with `kill -STOP <pid-of-program>'.
  48.  
  49. After the last announcement I got several bug reports about garbage on
  50. the screen after a menu was removed.  All these reports originated
  51. from people with the then pre-beta XS3 server.  I never discovered
  52. what the problem was since I couldn't duplicate it.
  53.  
  54. I would like to give special thanks to Karl Olav Lillevold
  55. <Karl.Lillevold@nta.no> who reported most of the problems and helped
  56. me with testing.
  57.  
  58. Rick Sladkey <jrs@world.std.com>
  59. -----
  60. diff -rcN orig/ups-2.45.2/lib/libmtrprog/ifdefs.h ups-2.45.2/lib/libmtrprog/ifdefs.h
  61. *** orig/ups-2.45.2/lib/libmtrprog/ifdefs.h    Fri Sep 18 12:16:47 1992
  62. --- ups-2.45.2/lib/libmtrprog/ifdefs.h    Sun Jan 16 22:21:28 1994
  63. ***************
  64. *** 57,62 ****
  65. --- 57,67 ----
  66.   #define clipper        1
  67.   #endif
  68.   
  69. + #ifdef __linux__
  70. + #undef linux
  71. + #define linux
  72. + #endif
  73.   /*  Which architecture?
  74.    */
  75.   #ifdef i386
  76. ***************
  77. *** 82,87 ****
  78. --- 87,98 ----
  79.   #define THIS_ARCH    "bsdi386"
  80.   #endif
  81.   
  82. + #if defined(linux) && defined(i386)
  83. + #undef ARCH_LINUX386
  84. + #define ARCH_LINUX386    1
  85. + #define THIS_ARCH    "linux386"
  86. + #endif
  87.   #if defined(sun) && defined(sparc)
  88.   #undef ARCH_SUN4
  89.   #define ARCH_SUN4    1
  90. ***************
  91. *** 150,155 ****
  92. --- 161,172 ----
  93.   #ifdef bsdi
  94.   #define OS_BSDI
  95.   #define THIS_OS        "bsdi"
  96. + #define OS_BSD
  97. + #endif
  98. + #ifdef linux
  99. + #define OS_LINUX
  100. + #define THIS_OS        "linux"
  101.   #define OS_BSD
  102.   #endif
  103.   
  104. diff -rcN orig/ups-2.45.2/lib/libx11wn/wn_event.c ups-2.45.2/lib/libx11wn/wn_event.c
  105. *** orig/ups-2.45.2/lib/libx11wn/wn_event.c    Wed Jul  1 08:28:34 1992
  106. --- ups-2.45.2/lib/libx11wn/wn_event.c    Sun Jan 16 22:21:28 1994
  107. ***************
  108. *** 1012,1025 ****
  109. --- 1012,1029 ----
  110.   
  111.       if (func != NULL) {
  112.           set_intr_event_mask(w);
  113. + #ifdef FASYNC
  114.           old_io_func = signal(SIGIO, catch_sigio);
  115.           if (fcntl(fd, F_SETFL, FASYNC) != 0)
  116.               wn__panic("FASYNC on botch");
  117. + #endif
  118.       }
  119.       else {
  120. + #ifdef FASYNC
  121.           (void) signal(SIGIO, old_io_func);
  122.           if (fcntl(fd, F_SETFL, 0) != 0)
  123.               wn__panic("FASYNC off botch");
  124. + #endif
  125.           set_normal_event_mask(w);
  126.       }
  127.   
  128. diff -rcN orig/ups-2.45.2/lib/libx11wn/wn_init.c ups-2.45.2/lib/libx11wn/wn_init.c
  129. *** orig/ups-2.45.2/lib/libx11wn/wn_init.c    Tue Sep 15 13:05:47 1992
  130. --- ups-2.45.2/lib/libx11wn/wn_init.c    Sun Jan 16 22:21:29 1994
  131. ***************
  132. *** 667,672 ****
  133. --- 667,673 ----
  134.   #endif
  135.       }
  136.   
  137. + #ifdef FASYNC
  138.       if (fcntl(fd, F_SETOWN, getpid()) != 0) {
  139.           if (errbuf != NULL) {
  140.               sprintf(errbuf,
  141. ***************
  142. *** 675,680 ****
  143. --- 676,682 ----
  144.           }
  145.           return -1;
  146.       }
  147. + #endif
  148.   
  149.       _wn_change_wn_fdmask(fd);
  150.       return 0;
  151. diff -rcN orig/ups-2.45.2/lib/libx11wn/wn_misc.c ups-2.45.2/lib/libx11wn/wn_misc.c
  152. *** orig/ups-2.45.2/lib/libx11wn/wn_misc.c    Sat Apr 25 10:09:24 1992
  153. --- ups-2.45.2/lib/libx11wn/wn_misc.c    Sun Jan 16 22:21:29 1994
  154. ***************
  155. *** 54,61 ****
  156. --- 54,63 ----
  157.   /*  BUG: this should be in ansi/stddef.h, but select() is so undefined
  158.    *  that I don't want it there.
  159.    */
  160. + #ifndef linux
  161.   int select PROTO((int nfds, int *ifds, int *ofds, int *efds,
  162.                               struct timeval *timeout));
  163. + #endif
  164.   
  165.   static char *store_set_selection PROTO((const char *data, int nbytes));
  166.   static char *store_got_selection PROTO((const char *data, int nbytes));
  167. diff -rcN orig/ups-2.45.2/ups/core.c ups-2.45.2/ups/core.c
  168. *** orig/ups-2.45.2/ups/core.c    Tue Sep 15 14:04:05 1992
  169. --- ups-2.45.2/ups/core.c    Sun Jan 16 22:21:31 1994
  170. ***************
  171. *** 31,37 ****
  172.   #include <signal.h>
  173.   #include <errno.h>
  174.   
  175. ! #ifndef OS_BSDI
  176.   #include <sys/vmparam.h>
  177.   #endif
  178.   
  179. --- 31,37 ----
  180.   #include <signal.h>
  181.   #include <errno.h>
  182.   
  183. ! #if !defined(OS_BSDI) && !defined(OS_LINUX)
  184.   #include <sys/vmparam.h>
  185.   #endif
  186.   
  187. ***************
  188. *** 75,81 ****
  189.   
  190.   #undef USERCORE
  191.   #if defined(OS_BSDI) || defined(OS_ULTRIX) || defined(ARCH_CLIPPER) || \
  192. !     defined(ARCH_VAX) || defined(OS_RISCOS) || defined(OS_NEWSOS)
  193.   #define USERCORE
  194.   #endif
  195.   
  196. --- 75,82 ----
  197.   
  198.   #undef USERCORE
  199.   #if defined(OS_BSDI) || defined(OS_ULTRIX) || defined(ARCH_CLIPPER) || \
  200. !     defined(ARCH_VAX) || defined(OS_RISCOS) || defined(OS_NEWSOS) || \
  201. !     defined(OS_LINUX)
  202.   #define USERCORE
  203.   #endif
  204.   
  205. diff -rcN orig/ups-2.45.2/ups/exec.c ups-2.45.2/ups/exec.c
  206. *** orig/ups-2.45.2/ups/exec.c    Thu Sep 17 17:00:14 1992
  207. --- ups-2.45.2/ups/exec.c    Sun Jan 30 23:38:18 1994
  208. ***************
  209. *** 103,109 ****
  210.           errf("Target not running");
  211.   }
  212.   
  213. ! #ifndef OS_SUNOS
  214.   /* ARGSUSED */
  215.   #endif
  216.   int
  217. --- 103,109 ----
  218.           errf("Target not running");
  219.   }
  220.   
  221. ! #if !defined(OS_SUNOS) && !defined(OS_LINUX)
  222.   /* ARGSUSED */
  223.   #endif
  224.   int
  225. ***************
  226. *** 111,117 ****
  227.   const char *name;
  228.   int pid;
  229.   {
  230. ! #ifndef OS_SUNOS
  231.       errf("This machine does not support attaching to running processes");
  232.       return -1;
  233.   #else
  234. --- 111,117 ----
  235.   const char *name;
  236.   int pid;
  237.   {
  238. ! #if !defined(OS_SUNOS) && !defined(OS_LINUX)
  239.       errf("This machine does not support attaching to running processes");
  240.       return -1;
  241.   #else
  242. ***************
  243. *** 146,152 ****
  244.       proc_set_base_sp(Current_proc, get_outer_fp());
  245.   
  246.       return 0;
  247. ! #endif /* !OS_SUNOS */
  248.   }
  249.   
  250.   void
  251. --- 146,152 ----
  252.       proc_set_base_sp(Current_proc, get_outer_fp());
  253.   
  254.       return 0;
  255. ! #endif /* !OS_SUNOS && !OS_LINUX */
  256.   }
  257.   
  258.   void
  259. diff -rcN orig/ups-2.45.2/ups/mreg.h ups-2.45.2/ups/mreg.h
  260. *** orig/ups-2.45.2/ups/mreg.h    Mon May  4 13:40:03 1992
  261. --- ups-2.45.2/ups/mreg.h    Sun Jan 16 22:21:32 1994
  262. ***************
  263. *** 36,41 ****
  264. --- 36,52 ----
  265.   #define N_UREGS            (N_UAREA_GREGS + 1)
  266.   #endif
  267.   
  268. + #ifdef OS_LINUX
  269. + #define N_UAREA_GREGS        17
  270. + #define UR_SP            15
  271. + #define UR_FP            5
  272. + #define UR_PC            12
  273. + #define N_UREGS            17
  274. + #define UPAGES 1
  275. + #define ctob(x)    (0x1000*(x))
  276. + #define USRSTACK 0xc0000000
  277. + #endif
  278.   #ifdef ARCH_CLIPPER
  279.   #define N_UAREA_GREGS        14    /* Clipper has r0..r13 as general regs */
  280.   
  281. ***************
  282. *** 71,77 ****
  283.    *  We try to abstract out some common code for these, and define
  284.    *  UAREA_REGS for #ifdefs.
  285.    */
  286. ! #if defined(OS_BSDI) || defined(ARCH_VAX) || defined(ARCH_MIPS) || defined(ARCH_CLIPPER)
  287.   #define UAREA_REGS
  288.   #endif
  289.   
  290. --- 82,89 ----
  291.    *  We try to abstract out some common code for these, and define
  292.    *  UAREA_REGS for #ifdefs.
  293.    */
  294. ! #if defined(OS_BSDI) || defined(ARCH_VAX) || defined(ARCH_MIPS) || \
  295. !     defined(ARCH_CLIPPER) || defined(OS_LINUX)
  296.   #define UAREA_REGS
  297.   #endif
  298.   
  299. diff -rcN orig/ups-2.45.2/ups/obj_env.c ups-2.45.2/ups/obj_env.c
  300. *** orig/ups-2.45.2/ups/obj_env.c    Sun Jul 26 12:55:55 1992
  301. --- ups-2.45.2/ups/obj_env.c    Sun Jan 16 22:21:32 1994
  302. ***************
  303. *** 27,33 ****
  304. --- 27,35 ----
  305.   #include "menudata.h"
  306.   #include "tdr.h"
  307.   
  308. + #ifndef OS_LINUX
  309.   extern const char **environ;
  310. + #endif
  311.   
  312.   /*  An element in the circular doubly linked list of environment entries.
  313.    */
  314. diff -rcN orig/ups-2.45.2/ups/obj_signal.c ups-2.45.2/ups/obj_signal.c
  315. *** orig/ups-2.45.2/ups/obj_signal.c    Sun Jul 26 12:50:21 1992
  316. --- ups-2.45.2/ups/obj_signal.c    Sun Jan 16 22:21:33 1994
  317. ***************
  318. *** 46,51 ****
  319. --- 46,88 ----
  320.   
  321.   #define SIG_DFL_NO_EFFECT      0    /* sig doesn't terminate proc by default */
  322.   
  323. + #ifdef OS_LINUX
  324. + static siginfo_t Sigtab[] = {
  325. +     "",          0,        
  326. +     "SIGHUP    (1) ", SIG_DFL_TERMINATES | SIG_CONT | SIG_ACCEPT,
  327. +     "SIGINT    (2) ", SIG_DFL_TERMINATES,
  328. +     "SIGQUIT   (3) ", SIG_DFL_TERMINATES | SIG_DFL_CORE,
  329. +     "SIGILL    (4) ", SIG_DFL_TERMINATES | SIG_DFL_CORE,
  330. +     "SIGTRAP   (5) ", SIG_DFL_TERMINATES | SIG_DFL_CORE,
  331. +     "SIGIOT    (6) ", SIG_DFL_TERMINATES | SIG_DFL_CORE,
  332. +     "SIGUNUSED (7) ", SIG_DFL_TERMINATES | SIG_DFL_CORE | SIG_CONT | SIG_ACCEPT,
  333. +     "SIGFPE    (8) ", SIG_DFL_TERMINATES | SIG_DFL_CORE | SIG_CONT | SIG_ACCEPT,
  334. +     "SIGKILL   (9) ", SIG_DFL_TERMINATES | SIG_CONT | SIG_ACCEPT,
  335. +     "SIGUSR1   (10)", SIG_DFL_TERMINATES,
  336. +     "SIGSEGV   (11)", SIG_DFL_TERMINATES | SIG_DFL_CORE,
  337. +     "SIGUSR2   (12)", SIG_DFL_TERMINATES,
  338. +     "SIGPIPE   (13)", SIG_DFL_TERMINATES,
  339. +     "SIGALRM   (14)", SIG_DFL_TERMINATES | SIG_CONT | SIG_ACCEPT,
  340. +     "SIGTERM   (15)", SIG_DFL_TERMINATES,
  341. +     "SIGSTKFLT (16)", SIG_DFL_NO_EFFECT  | SIG_CONT | SIG_ACCEPT,
  342. +     "SIGCHLD   (17)", SIG_DFL_NO_EFFECT  | SIG_CONT | SIG_ACCEPT,
  343. +     "SIGCONT   (18)", SIG_DFL_NO_EFFECT  | SIG_CONT | SIG_ACCEPT,
  344. +     "SIGSTOP   (19)", SIG_DFL_STOPS,    
  345. +     "SIGTSTP   (20)", SIG_DFL_STOPS      | SIG_CONT | SIG_ACCEPT,    
  346. +     "SIGTTIN   (21)", SIG_DFL_STOPS,
  347. +     "SIGTTOU   (22)", SIG_DFL_STOPS,
  348. +     "SIGIO     (23)", SIG_DFL_NO_EFFECT  | SIG_CONT | SIG_ACCEPT,    
  349. +     "SIGXCPU   (24)", SIG_DFL_TERMINATES,    
  350. +     "SIGXFSZ   (25)", SIG_DFL_TERMINATES,    
  351. +     "SIGVTALARM(26)", SIG_DFL_TERMINATES | SIG_CONT | SIG_ACCEPT,    
  352. +     "SIGPROF   (27)", SIG_DFL_TERMINATES,    
  353. +     "SIGWINCH  (28)", SIG_DFL_NO_EFFECT  | SIG_CONT | SIG_ACCEPT,    
  354. +     "SIGLOST   (29)", SIG_DFL_TERMINATES,
  355. +     "SIGPWR    (30)", SIG_DFL_TERMINATES,    
  356. +     "SIG31     (31)", SIG_DFL_TERMINATES,    
  357. +     "SIG32     (32)", SIG_DFL_TERMINATES,    
  358. + };
  359. + #else
  360.   static siginfo_t Sigtab[] = {
  361.       "",          0,        
  362.       "SIGHUP    (1) ", SIG_DFL_TERMINATES | SIG_CONT | SIG_ACCEPT,
  363. ***************
  364. *** 80,85 ****
  365. --- 117,123 ----
  366.       "SIGUSR1   (30)", SIG_DFL_TERMINATES,    
  367.       "SIGUSR2   (31)", SIG_DFL_TERMINATES,    
  368.   };
  369. + #endif
  370.   
  371.   const char Sig_format[] = "signal %[-]15cs%[-]46cs\n";
  372.   
  373. ***************
  374. *** 142,148 ****
  375.   sig_is_fatal(sig)
  376.   int sig;
  377.   {
  378. !     return sig == SIGILL || sig == SIGSEGV || sig == SIGBUS;
  379.   }
  380.   
  381.   const char *
  382. --- 180,196 ----
  383.   sig_is_fatal(sig)
  384.   int sig;
  385.   {
  386. !     return 0
  387. ! #ifdef SIGILL
  388. !         || sig == SIGILL
  389. ! #endif
  390. ! #ifdef SIGSEGV
  391. !         || sig == SIGSEGV
  392. ! #endif
  393. ! #ifdef SIGBUG
  394. !         || sig == SIGBUS
  395. ! #endif
  396. !             ;
  397.   }
  398.   
  399.   const char *
  400. diff -rcN orig/ups-2.45.2/ups/obj_target.c ups-2.45.2/ups/obj_target.c
  401. *** orig/ups-2.45.2/ups/obj_target.c    Sun Jul 26 13:01:27 1992
  402. --- ups-2.45.2/ups/obj_target.c    Sun Jan 16 22:21:33 1994
  403. ***************
  404. *** 36,41 ****
  405. --- 36,45 ----
  406.   #include "state.h"
  407.   #include "tdr.h"
  408.   
  409. + #ifdef OS_LINUX
  410. + #define NCARGS ARG_MAX
  411. + #endif
  412.   static int args_quitfunc PROTO((struct edescst *edesc, int unused_n_tries));
  413.   static void args_edit PROTO((struct drawst fdets));
  414.   
  415. diff -rcN orig/ups-2.45.2/ups/proc.c ups-2.45.2/ups/proc.c
  416. *** orig/ups-2.45.2/ups/proc.c    Thu Sep 17 17:03:02 1992
  417. --- ups-2.45.2/ups/proc.c    Sun Jan 30 22:37:06 1994
  418. ***************
  419. *** 49,55 ****
  420. --- 49,57 ----
  421.   #include <signal.h>
  422.   #include <sys/dir.h>        /* VAX needs this for user.h */
  423.   #include <sys/user.h>
  424. + #ifndef OS_LINUX
  425.   #include <machine/reg.h>
  426. + #endif
  427.   #include <errno.h>
  428.   extern int errno;    /* some versions on errno.h don't declare this */
  429.   
  430. ***************
  431. *** 87,93 ****
  432.   #include <sys/ptrace.h>
  433.   #endif
  434.   
  435. ! #ifndef OS_SUNOS
  436.   
  437.   /*  Word size (and alignment) for ptrace read/write data requests.
  438.    *
  439. --- 89,101 ----
  440.   #include <sys/ptrace.h>
  441.   #endif
  442.   
  443. ! #ifdef OS_LINUX
  444. ! #include <sys/ptrace.h>
  445. ! #define PTRACE_PEEKUSER PTRACE_PEEKUSR
  446. ! #define PTRACE_POKEUSER PTRACE_POKEUSR
  447. ! #endif
  448. ! #if !defined(OS_SUNOS)
  449.   
  450.   /*  Word size (and alignment) for ptrace read/write data requests.
  451.    *
  452. ***************
  453. *** 95,100 ****
  454. --- 103,109 ----
  455.    */
  456.   #define WORDSIZE    4
  457.   
  458. + #ifndef OS_LINUX
  459.   #if defined(ARCH_MIPS) && (defined(OS_ULTRIX) || defined(OS_RISCOS))
  460.   /* Request values for the ptrace system call
  461.    */
  462. ***************
  463. *** 137,149 ****
  464. --- 146,163 ----
  465.       PTRACE_SINGLESTEP =    9    /* single step process */
  466.   };
  467.   #endif /* !(OS_ULTRIX && OS_MIPS) */
  468. + #endif /* !OS_LINUX */
  469.   #endif /* !OS_SUNOS */
  470.   
  471.   #ifndef WSTOPSIG
  472.   #define WSTOPSIG(w)    ((w).w_stopsig)
  473.   #endif
  474.   
  475. + #ifdef OS_LINUX
  476. + typedef int ptracereq_t;
  477. + #else
  478.   typedef enum ptracereq ptracereq_t;
  479. + #endif
  480.   
  481.   #ifdef PTRACE_DEBUG
  482.   static int ptrace_debug PROTO((int request, int pid, int addr, int data));
  483. ***************
  484. *** 154,162 ****
  485. --- 168,180 ----
  486.   int ptrace PROTO((ptracereq_t req, int pid, char *addr, int data, char *addr2));
  487.   #define std_ptrace(req, pid, addr, data)    ptrace(req, pid, addr, data, (char *)NULL)
  488.   #else
  489. + #ifdef OS_LINUX
  490. + #define std_ptrace(req, pid, addr, data)    ptrace(req, pid, (int) addr, data)
  491. + #else
  492.   int ptrace PROTO((ptracereq_t req, int pid, char *addr, int data));
  493.   #define std_ptrace(req, pid, addr, data)    ptrace(req, pid, addr, data)
  494.   #endif
  495. + #endif
  496.   
  497.   /*  Return the offset into the u area of member.
  498.    *  Used when doing PEEKUSER ptrace requests.
  499. ***************
  500. *** 193,199 ****
  501.   #define INTEGER_REG(sr, regno)    ((&(sr)->sr_regs.r_y)[regno])
  502.   #endif
  503.   
  504. ! #if defined(OS_SUNOS) || defined(OS_BSDI)
  505.   typedef int wait_arg_t;
  506.   #define WAIT_STATUS_IS_INT
  507.   #else
  508. --- 211,217 ----
  509.   #define INTEGER_REG(sr, regno)    ((&(sr)->sr_regs.r_y)[regno])
  510.   #endif
  511.   
  512. ! #if defined(OS_SUNOS) || defined(OS_BSDI) || defined(OS_LINUX)
  513.   typedef int wait_arg_t;
  514.   #define WAIT_STATUS_IS_INT
  515.   #else
  516. ***************
  517. *** 279,284 ****
  518. --- 297,309 ----
  519.   #define GET_OPCODE_FROM_WORD(w)        ((w) & 0xff)
  520.   #endif
  521.   
  522. + #ifdef ARCH_LINUX386
  523. + #define BPT                0xcc        /* int $3 */
  524. + #define BPT_PC_OFFSET            1
  525. + #define PUT_OPCODE_IN_WORD(w, data)    (((w) & ~0xff) | (data & 0xff))
  526. + #define GET_OPCODE_FROM_WORD(w)        ((w) & 0xff)
  527. + #endif
  528.   #ifdef ARCH_SUN386
  529.   #define BPT                0xcc        /* int $3 */
  530.   #define BPT_PC_OFFSET            1
  531. ***************
  532. *** 396,401 ****
  533. --- 421,434 ----
  534.   {
  535.       int res;
  536.   
  537. + #ifdef ARCH_LINUX386
  538. +     if (req == PTRACE_CONT || req == PTRACE_SINGLESTEP) {
  539. +         if (addr != (char *) 1) {
  540. +             std_ptrace(PTRACE_POKEUSER, pid, 4*EIP, addr);
  541. +             addr = (char *) 1;
  542. +         }
  543. +     }
  544. + #endif
  545.       errno = 0;
  546.       res = std_ptrace(req, pid, addr, data);
  547.       if (errno != 0)
  548. ***************
  549. *** 456,461 ****
  550. --- 489,500 ----
  551.           ur[i].ur_uaddr = (int)U_OFFSET(u_pcb.pcb_regs[i]);
  552.       ur[UR_PC].ur_uaddr = (int)U_OFFSET(u_pcb.pcb_cxt.cxt_pc);
  553.   #endif
  554. + #ifdef ARCH_LINUX386
  555. +     int i;
  556. +     for (i = 0; i <= 16; i++)
  557. +         ur[i].ur_uaddr = 4*i;
  558. + #endif
  559.   }
  560.   #endif /* !ARCH_BSDI386 */
  561.   
  562. ***************
  563. *** 1084,1090 ****
  564.       return ((iproc_t *)proc)->ip_base_sp;
  565.   }
  566.   
  567. ! #ifdef OS_SUNOS
  568.   proc_t
  569.   proc_attach(path, pid, p_whystopped)
  570.   const char *path;
  571. --- 1123,1129 ----
  572.       return ((iproc_t *)proc)->ip_base_sp;
  573.   }
  574.   
  575. ! #if defined(OS_SUNOS) || defined(OS_LINUX)
  576.   proc_t
  577.   proc_attach(path, pid, p_whystopped)
  578.   const char *path;
  579. ***************
  580. *** 1100,1106 ****
  581.       *p_whystopped = ip->ip_whystopped;
  582.       return (proc_t)ip;
  583.   }
  584. ! #endif /* OS_SUNOS */
  585.   
  586.   /*  Kill off the target process
  587.    */
  588. --- 1139,1145 ----
  589.       *p_whystopped = ip->ip_whystopped;
  590.       return (proc_t)ip;
  591.   }
  592. ! #endif /* OS_SUNOS || OS_LINUX */
  593.   
  594.   /*  Kill off the target process
  595.    */
  596. ***************
  597. *** 1565,1571 ****
  598.   #ifdef ARCH_CLIPPER
  599.       taddr_t saved_sp, saved_regs[N_REG_ARGS];
  600.   #endif
  601. ! #ifdef ARCH_BSDI386
  602.       taddr_t saved_regs[N_UREGS];
  603.   #endif
  604.       breakpoint_t breakpoint;
  605. --- 1604,1610 ----
  606.   #ifdef ARCH_CLIPPER
  607.       taddr_t saved_sp, saved_regs[N_REG_ARGS];
  608.   #endif
  609. ! #if defined(ARCH_BSDI386) || defined(ARCH_LINUX386)
  610.       taddr_t saved_regs[N_UREGS];
  611.   #endif
  612.       breakpoint_t breakpoint;
  613. ***************
  614. *** 1657,1663 ****
  615.           saved_regs[i] = proc_getreg(proc, i);
  616.       sp = saved_sp = proc_getreg(proc, REG_SP);
  617.   #endif
  618. ! #ifdef ARCH_BSDI386
  619.       for (i = 0; i < N_UREGS; ++i)
  620.           if (get_uarea_reg(ip, i, &saved_regs[i]) != 0)
  621.               panic("can't get reg in pcf");
  622. --- 1696,1702 ----
  623.           saved_regs[i] = proc_getreg(proc, i);
  624.       sp = saved_sp = proc_getreg(proc, REG_SP);
  625.   #endif
  626. ! #if defined(ARCH_BSDI386) || defined(ARCH_LINUX386)
  627.       for (i = 0; i < N_UREGS; ++i)
  628.           if (get_uarea_reg(ip, i, &saved_regs[i]) != 0)
  629.               panic("can't get reg in pcf");
  630. ***************
  631. *** 1761,1767 ****
  632.           return -1;
  633.       }
  634.   #endif /* ARCH_VAX */
  635. ! #if defined(ARCH_SUN3) || defined(ARCH_SUN386) || defined(ARCH_CLIPPER) || defined(ARCH_BSDI386)
  636.       sp -= 4;
  637.       if (proc_write_data(proc, sp, (char *)&retpc, sizeof(retpc)) != 0) {
  638.           *p_mesg = "Can't push return address";
  639. --- 1800,1807 ----
  640.           return -1;
  641.       }
  642.   #endif /* ARCH_VAX */
  643. ! #if defined(ARCH_SUN3) || defined(ARCH_SUN386) || defined(ARCH_CLIPPER) || \
  644. !     defined(ARCH_BSDI386) || defined(ARCH_LINUX386)
  645.       sp -= 4;
  646.       if (proc_write_data(proc, sp, (char *)&retpc, sizeof(retpc)) != 0) {
  647.           *p_mesg = "Can't push return address";
  648. ***************
  649. *** 1793,1799 ****
  650.       proc_setreg(proc, REG_FP, fp);
  651.       proc_setreg(proc, REG_SP, sp);
  652.   #endif /* ARCH_VAX */
  653. ! #if defined(ARCH_SUN3) || defined(ARCH_SUN386) || defined(ARCH_BSDI386)
  654.       proc_setreg(proc, REG_SP, sp);
  655.   #endif
  656.   #ifdef ARCH_MIPS
  657. --- 1833,1840 ----
  658.       proc_setreg(proc, REG_FP, fp);
  659.       proc_setreg(proc, REG_SP, sp);
  660.   #endif /* ARCH_VAX */
  661. ! #if defined(ARCH_SUN3) || defined(ARCH_SUN386) || defined(ARCH_BSDI386) || \
  662. !     defined(ARCH_LINUX386)
  663.       proc_setreg(proc, REG_SP, sp);
  664.   #endif
  665.   #ifdef ARCH_MIPS
  666. ***************
  667. *** 1908,1913 ****
  668. --- 1949,1959 ----
  669.           if (set_uarea_reg(ip, i, saved_regs[i]) != 0)
  670.               panic("can't restore regs in cf");
  671.   #endif
  672. + #ifdef ARCH_LINUX386
  673. +     for (i = 0; i < N_UREGS; ++i)
  674. +         if (i != ORIG_EAX && set_uarea_reg(ip, i, saved_regs[i]) != 0)
  675. +             panic("can't restore regs in cf");
  676. + #endif
  677.   
  678.       /*  Wait for target will have set ip_restart_pc to retpc, because
  679.        *  that is where the function returned.  We put this back.
  680. ***************
  681. *** 1952,1958 ****
  682.   proc_get_retaddr_after_jsr(proc)
  683.   proc_t proc;
  684.   {
  685. ! #if defined(ARCH_SUN3) || defined(ARCH_SUN386) || defined(ARCH_CLIPPER) || defined(ARCH_BSDI386)
  686.       taddr_t sp, retaddr;
  687.   
  688.       sp = proc_getreg(proc, REG_SP);
  689. --- 1998,2005 ----
  690.   proc_get_retaddr_after_jsr(proc)
  691.   proc_t proc;
  692.   {
  693. ! #if defined(ARCH_SUN3) || defined(ARCH_SUN386) || defined(ARCH_CLIPPER) || \
  694. !     defined(ARCH_BSDI386) || defined(ARCH_LINUX386)
  695.       taddr_t sp, retaddr;
  696.   
  697.       sp = proc_getreg(proc, REG_SP);
  698. ***************
  699. *** 2136,2142 ****
  700. --- 2183,2193 ----
  701.   #ifdef ARCH_SUN4
  702.       uaddr = U_OFFSET(u_signal[sig]) + sparc_u_offset();
  703.   #else
  704. + #ifdef ARCH_LINUX386
  705. +     uaddr = 0; /* XXX */
  706. + #else
  707.       uaddr = U_OFFSET(u_signal[sig]);
  708. + #endif
  709.   #endif
  710.   #endif
  711.   #endif
  712. diff -rcN orig/ups-2.45.2/ups/st_parse.c ups-2.45.2/ups/st_parse.c
  713. *** orig/ups-2.45.2/ups/st_parse.c    Tue Feb  9 15:47:58 1993
  714. --- ups-2.45.2/ups/st_parse.c    Sat Jan 29 08:59:47 1994
  715. ***************
  716. *** 255,262 ****
  717.       s = *p_s;
  718.       if (!isdigit(*s))
  719.           panic("bad number in parse_num");
  720. !     while (*s != '\0' && isdigit(*s))
  721. !         res = res * 10 + *s++ - '0';
  722.       *p_s = s;
  723.       return res;
  724.   }
  725. --- 255,284 ----
  726.       s = *p_s;
  727.       if (!isdigit(*s))
  728.           panic("bad number in parse_num");
  729. !     if (*s == '0') {
  730. !         s++;
  731. !         if (*s == 'x' || *s == 'X') {
  732. !             s++;
  733. !             for (;;) {
  734. !                 if (isdigit(*s))
  735. !                     res = res * 16 + *s++ - '0';
  736. !                 else if (*s >= 'A' && *s <= 'F')
  737. !                     res = res * 16 + *s++ - 'A' + 10;
  738. !                 else if (*s >= 'a' && *s <= 'f')
  739. !                     res = res * 16 + *s++ - 'a' + 10;
  740. !                 else
  741. !                     break;
  742. !             }
  743. !         }
  744. !         else {
  745. !             while (*s >= '0' && *s <= '7')
  746. !                 res = res * 8 + *s++ - '0';
  747. !         }
  748. !     }
  749. !     else {
  750. !         while (isdigit(*s))
  751. !             res = res * 10 + *s++ - '0';
  752. !     }
  753.       *p_s = s;
  754.       return res;
  755.   }
  756. ***************
  757. *** 379,384 ****
  758. --- 401,410 ----
  759.           0,        -1,        TY_UINT,    sizeof(long),
  760.           4,        0,        TY_FLOAT,    sizeof(float),
  761.           8,        0,        TY_DOUBLE,    sizeof(double),
  762. + #if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
  763. +         12,        0,        TY_LONG_DOUBLE,
  764. +             sizeof(long double),
  765. + #endif
  766.       };
  767.   #define N_C_TYPES    (sizeof c_typetab / sizeof *c_typetab)
  768.       static f77_typetab_t f77_typetab[] = {
  769. diff -rcN orig/ups-2.45.2/ups/st_skim.c ups-2.45.2/ups/st_skim.c
  770. *** orig/ups-2.45.2/ups/st_skim.c    Tue Sep 15 13:58:19 1992
  771. --- ups-2.45.2/ups/st_skim.c    Sun Jan 30 00:37:12 1994
  772. ***************
  773. *** 563,568 ****
  774. --- 563,569 ----
  775.                   name = symstring(st->st_symio_id, symno);
  776.                   stf->stf_name = name;
  777.   
  778. + #ifdef CFRONT_KLUDGES
  779.                   /*  We don't change the filename for .h files.
  780.                    *  DJ Delorie <dj@ctron.com> says this makes
  781.                    *  ups work better with cfront (c++).
  782. ***************
  783. *** 570,575 ****
  784. --- 571,582 ----
  785.                   if (name != NULL &&
  786.                       strcmp(name + strlen(name) - 2, ".h") != 0)
  787.                       sfiles->fi_name = stf->stf_name;
  788. + #else
  789. +                 /*  We need to changes filenames for .h files,
  790. +                  *  otherwise inline functions don't work.
  791. +                  */
  792. +                 sfiles->fi_name = stf->stf_name;
  793. + #endif
  794.               }
  795.               break;
  796.   
  797. diff -rcN orig/ups-2.45.2/ups/stack.c ups-2.45.2/ups/stack.c
  798. *** orig/ups-2.45.2/ups/stack.c    Wed May 20 17:11:43 1992
  799. --- ups-2.45.2/ups/stack.c    Sun Jan 16 22:21:36 1994
  800. ***************
  801. *** 22,28 ****
  802. --- 22,30 ----
  803.   #include <machine/machparam.h>
  804.   #include <machine/vmparam.h>    /* for USRSTACK */
  805.   #else
  806. + #ifndef OS_LINUX
  807.   #include <machine/frame.h>
  808. + #endif
  809.   #endif /* !ARCH_CLIPPER */
  810.   #endif /* !ARCH_MIPS */
  811.   
  812. ***************
  813. *** 47,53 ****
  814.   #include "mips_frame.h"
  815.   #endif /* ARCH_MIPS */
  816.   
  817. ! #ifdef ARCH_BSDI386
  818.   /*  There is no <machine/frame.h> on the BSDi box.  This is what a
  819.    *  stack frame looks like.  Don't add to this - the signal handling
  820.    *  code in build_stack_trace depends on the size of this struct.
  821. --- 49,55 ----
  822.   #include "mips_frame.h"
  823.   #endif /* ARCH_MIPS */
  824.   
  825. ! #if defined(ARCH_BSDI386) || defined(ARCH_LINUX386)
  826.   /*  There is no <machine/frame.h> on the BSDi box.  This is what a
  827.    *  stack frame looks like.  Don't add to this - the signal handling
  828.    *  code in build_stack_trace depends on the size of this struct.
  829. ***************
  830. *** 383,389 ****
  831. --- 385,393 ----
  832.       preamble_t *pr;
  833.       bool must_find_fp;
  834.   #endif
  835. + #ifndef OS_LINUX
  836.       struct sigcontext scbuf;
  837. + #endif
  838.       int lnum;
  839.       bool normal_frame;
  840.       taddr_t pc, fp, sp;
  841. ***************
  842. *** 427,432 ****
  843. --- 431,442 ----
  844.           }
  845.   #if defined(ARCH_VAX) || defined(ARCH_CLIPPER) || defined(ARCH_BSDI386)
  846.           if (*f->fu_name == '[' && strcmp(f->fu_name, "[start]") == 0) {
  847. +             fp = NULL;
  848. +             break;
  849. +         }
  850. + #endif
  851. + #ifdef ARCH_LINUX386
  852. +         if (strcmp(f->fu_name, "_entry") == 0) {
  853.               fp = NULL;
  854.               break;
  855.           }
  856. diff -rcN orig/ups-2.45.2/ups/symtab.h ups-2.45.2/ups/symtab.h
  857. *** orig/ups-2.45.2/ups/symtab.h    Thu Sep 17 08:36:24 1992
  858. --- ups-2.45.2/ups/symtab.h    Sat Jan 29 09:24:59 1994
  859. ***************
  860. *** 66,73 ****
  861. --- 66,76 ----
  862.       TY_UINT,        /* unsigned int */
  863.       TY_LONG,        /* long integer */
  864.       TY_ULONG,    /* unsigned long */
  865. +     TY_LONG_LONG,    /* long long integer */
  866. +     TY_ULONG_LONG,    /* long long integer */
  867.       TY_FLOAT,    /* floating point */
  868.       TY_DOUBLE,    /* double word */
  869. +     TY_LONG_DOUBLE,    /* long double floating point */
  870.       TY_INT_ASSUMED,    /* unknown - int assumed */
  871.   
  872.   /* FORTRAN base types */
  873. diff -rcN orig/ups-2.45.2/ups/text.c ups-2.45.2/ups/text.c
  874. *** orig/ups-2.45.2/ups/text.c    Wed May 20 17:11:41 1992
  875. --- ups-2.45.2/ups/text.c    Sun Jan 16 22:21:36 1994
  876. ***************
  877. *** 149,154 ****
  878. --- 149,158 ----
  879.   #define MOVL_ESP_EBP    0x89e5
  880.   #endif
  881.   
  882. + #ifdef OS_LINUX
  883. + #define MOVL_ESP_EBP    0x89e5
  884. + #endif
  885.   #define SWAP_SHORT(x)        ((x >> 8) | (((x) & 0xff) << 8))
  886.   #define SW_MOVL_ESP_EBP        SWAP_SHORT(MOVL_ESP_EBP)
  887.   #define SW_SUBL_IMM_ESP        SWAP_SHORT(SUBL_IMM_ESP)
  888. diff -rcN orig/ups-2.45.2/ups/ups.c ups-2.45.2/ups/ups.c
  889. *** orig/ups-2.45.2/ups/ups.c    Sun Sep 13 15:17:47 1992
  890. --- ups-2.45.2/ups/ups.c    Sun Jan 16 22:21:37 1994
  891. ***************
  892. *** 130,140 ****
  893. --- 130,150 ----
  894.            */
  895.   
  896.           switch (sig) {
  897. + #ifdef SIGSEGV
  898.           case SIGSEGV:    sigstr = "segmentation fault";        break;
  899. + #endif
  900. + #ifdef SIGBUG
  901.           case SIGBUS:    sigstr = "bus error";            break;
  902. + #endif
  903. + #ifdef SIGILL
  904.           case SIGILL:    sigstr = "illegal instruction";        break;
  905. + #endif
  906. + #ifdef SIGFPE
  907.           case SIGFPE:    sigstr = "floating point exception";    break;
  908. + #endif
  909. + #ifdef SIGQUIT
  910.           case SIGQUIT:    sigstr = "SIGQUIT";            break;
  911. + #endif
  912.           default:    sigstr = NULL;                break;
  913.           }
  914.   
  915. ***************
  916. *** 308,314 ****
  917.   char **argv;
  918.   {
  919.       static const int siglist[] = {
  920. !         SIGQUIT, SIGILL, SIGIOT, SIGEMT, SIGFPE, SIGSEGV, SIGSYS, SIGBUS,
  921.       };
  922.       static const char *(*vfuncs[])PROTO((void)) = {
  923.           arg_version, 
  924. --- 318,347 ----
  925.   char **argv;
  926.   {
  927.       static const int siglist[] = {
  928. ! #ifdef SIGQUIT
  929. !         SIGQUIT,
  930. ! #endif
  931. ! #ifdef SIGILL
  932. !         SIGILL,
  933. ! #endif
  934. ! #ifdef SIGIOT
  935. !         SIGIOT,
  936. ! #endif
  937. ! #ifdef SIGEMT
  938. !         SIGEMT,
  939. ! #endif
  940. ! #ifdef SIGFPE
  941. !         SIGFPE,
  942. ! #endif
  943. ! #ifdef SIGSEGV
  944. !         SIGSEGV,
  945. ! #endif
  946. ! #ifdef SIGSYS
  947. !         SIGSYS,
  948. ! #endif
  949. ! #ifdef SIGBUG
  950. !         SIGBUS,
  951. ! #endif
  952.       };
  953.       static const char *(*vfuncs[])PROTO((void)) = {
  954.           arg_version, 
  955. diff -rcN orig/ups-2.45.2/ups/va_val.c ups-2.45.2/ups/va_val.c
  956. *** orig/ups-2.45.2/ups/va_val.c    Tue Sep 15 14:00:34 1992
  957. --- ups-2.45.2/ups/va_val.c    Sat Jan 29 09:10:45 1994
  958. ***************
  959. *** 446,451 ****
  960. --- 446,459 ----
  961.           if (DREAD_VAR(addr, vl.vl_int))
  962.               int_to_string(buf, sizeof(buf), vl.vl_int, dv->dv_format);
  963.           break;
  964. +     case TY_LONG_LONG:
  965. +     case TY_ULONG_LONG:
  966. + #if defined(__GNUC__) || defined(HAVE_LONG_LONG)
  967. +         strcpy(buf, "<support for long long is unfinished>");
  968. + #else
  969. +         strcpy(buf, "<recompile UPS with GCC to use long long>");
  970. + #endif
  971. +         break;
  972.       case TY_UNION:
  973.       case TY_STRUCT:
  974.       case TY_U_STRUCT:
  975. ***************
  976. *** 461,466 ****
  977. --- 469,481 ----
  978.           if (dread_fpval(addr, v->va_class == CL_REG, TRUE,
  979.                              (char *)&vl.vl_double) == 0)
  980.               strcpy(buf, get_real(vl, want_hex, FALSE));
  981. +         break;
  982. +     case TY_LONG_DOUBLE:
  983. + #if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
  984. +         strcpy(buf, "<support for long double is unfinished>");
  985. + #else
  986. +         strcpy(buf, "<recompile UPS with GCC to use long double>");
  987. + #endif
  988.           break;
  989.       case TY_ENUM:
  990.       case TY_U_ENUM:
  991.